package com.atguigu.bigdata.spark.core.rdd.operator.transform;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;

import java.util.Arrays;
import java.util.List;

public class Spark05_RDD_Operator_Transform_JAVA {
    public static void main(String[] args) {
        //算子 - glom
        //将同一个分区的数据直接转换为相同类型的内存数组进行处理，分区不变
        SparkConf conf = new SparkConf().setMaster("local[*]").setAppName("sparkCore");
        JavaSparkContext sc = new JavaSparkContext(conf);

        List<Integer> list = Arrays.asList(1,2,3,4,5);

        JavaRDD<Integer> rdd = sc.parallelize(list,2);
        JavaRDD<List<Integer>> glomRdd = rdd.glom();

        List<List<Integer>> res = glomRdd.collect();

        for(List<Integer> val : res) {
            for(Integer value : val) {
                System.out.println(value);
            }
        }
        sc.stop();

    }
}
